package com.coin900.coin.cmd.sop;

import com.google.gson.Gson;
import com.coin900.coin.base.FuConstants;
import com.coin900.coin.cmd.ACmd;
import com.coin900.coin.cmd.CmdSign;
import com.coin900.coin.code.CmdCode;
import com.coin900.coin.persist.fu.FuUserVO;
import com.coin900.coin.persist.sop.SopUserVO;
import com.coin900.coin.service.sop.ISopUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;

/**
 * 运维人员信息新增
 *
 * @author shui
 * @create 2018-01-09
 **/
@Controller
public class SopUserPostCmd extends ACmd {
    @Override
    public CmdSign execute(HttpServletRequest request, CmdSign sign) throws Exception {
        CmdSign respSign = new CmdSign(sign);
        FuUserVO user = super.getUser(sign);
        String source = sign.getSource();
        SopUserVO sopUserVO = new Gson().fromJson(source, SopUserVO.class);
        sopUserVO.setCreatedInfor(user);
        this.userService.insertSopUser(sopUserVO);
        return respSign;
    }

    @Autowired
    private ISopUserService userService;

    @Override
    public String getCmdCode() {
        return CmdCode.SOP_USER_POST;
    }
}
